# Huawei Technologies Co.,Ltd.

set(RETURN_UNDEFINED_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/returnundefined.txt)
set(RETURN_UNDEFINED_BIN ${CMAKE_CURRENT_BINARY_DIR}/returnundefined.abc)
set(RETURN_UNDEFINED_JS ${CMAKE_CURRENT_SOURCE_DIR}/returnundefined.js)
set(RETURN_UNDEFINED_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${RETURN_UNDEFINED_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${RETURN_UNDEFINED_OUTPUT}
    COMMENT "running javascript returnundefined testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${RETURN_UNDEFINED_JS} --output ${RETURN_UNDEFINED_BIN}
    COMMAND rm -f ${RETURN_UNDEFINED_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${RETURN_UNDEFINED_OUTPUT}
    COMMAND bash ${RETURN_UNDEFINED_VERIFY} ${RETURN_UNDEFINED_OUTPUT}
)
add_custom_target(returnundefined
    DEPENDS ${RETURN_UNDEFINED_OUTPUT} ${RETURN_UNDEFINED_VERIFY}
)
add_dependencies(returnundefined es2panda ark)
add_dependencies(ecmascript_common_tests returnundefined)
